package com.lcg.liteflow.chain2;

import com.alibaba.fastjson.JSON;
import com.lcg.liteflow.dao.TestUser;
import com.lcg.liteflow.dao.TestUserMapper;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;


/**
 * @author: LCG
 * @date: 2023-03-22 14:04:14
 * @description:
 **/
@LiteflowComponent("pa")
public class PaCompant1 extends NodeComponent {

    @Autowired
    private TestUserMapper testUserMapper;

    @Override
    public void process() throws Exception {

        TestUser testUser = testUserMapper.selectById(1L);

        testUser.setLoginName(testUser.getLoginName()+"COPY");

        int updateById = testUserMapper.updateById(testUser);

        System.out.println("===事务的测试==="+updateById);

        System.out.println("====DATA==="+JSON.toJSONString(testUser));

        //参数传递进组件后
        ParamMap contextBean = getRequestData();
        System.out.println("aaa->"+JSON.toJSONString(contextBean));
        //在这里修改参数的值，可以传入到下一个组件，因为该参数是在ThreadLocal中存储进行传递的
        contextBean.setUserName("李四发财");
    }
}
